<?php
/**
 * Block Name: 网站首页主项目导航
 * */
function blocker_block_ad1_info(){
	return array(
        'info'  => t('AD-HOMEPAGE-MAIN-1:网站首页主项目导航'),
        /*
            DRUPAL_CACHE_PER_ROLE (default): The block can change depending on the roles the user viewing the page belongs to.
            DRUPAL_CACHE_PER_USER: The block can change depending on the user viewing the page. This setting can be resource-consuming for sites with large number of users, and should only be used when DRUPAL_CACHE_PER_ROLE is not sufficient.
            DRUPAL_CACHE_PER_PAGE: The block can change depending on the page being viewed.
            DRUPAL_CACHE_GLOBAL: The block is the same for every user on every page where it is visible.
            DRUPAL_NO_CACHE: The block should not get cached.
        */
        'cache' => '-1',
        'properties' => 1,
        'weight' => 0,
        /*
            BLOCK_VISIBILITY_NOTLISTED: Show on all pages except listed pages. 'pages' lists the paths where the block should not be shown.
            BLOCK_VISIBILITY_LISTED: Show only on listed pages. 'pages' lists the paths where the block should be shown.
            BLOCK_VISIBILITY_PHP: Use custom PHP code to determine visibility. 'pages' gives the PHP code to use.

        */
        'visibility' => BLOCK_VISIBILITY_NOTLISTED,
        'pages' => null
    );
}

function blocker_block_ad1_view($delta){
    
	$mainProjects = array(
        array('/misc/glools/mainprojects/ols.png', 'http://www.glools.net/ols'),
        array('/misc/glools/mainprojects/share-course.png', 'sharecourse'),
        array('/misc/glools/mainprojects/join.png', 'http://www.glools.com'),
        array('/misc/glools/mainprojects/try.png', 'http://www.glools.com'),
        array('/misc/glools/mainprojects/please.png', 'http://www.glools.com')
    );
    
    $links = array();
    foreach($mainProjects as $p){
        $image = theme('image',array(
            'path' => $p[0],
            'width' => '160',
            'alt' => 'GLOOLS MAIGOR PROJECT',
            'title' => 'GLOOLS MAIGOR PROJECT'
        ));
    	$links[] = l($image, $p[1], array('html'=>true, 'attributes'=>array('target'=>'_blank')));
    }
    
    $itemListVariables = array(
        'items'=>$links,
        'type'=>'ul',
        'attributes'=>array(
            'class' => 'ProjectsContent'
        ),
        'containerAttributes'=>array(
            'class' => 'ProjectsContainer'
        )
    );
    
    drupal_add_css(path_to_theme().'/css/block-blocker-ad1.css');
    
    return array(
        'subject' => '',
        'content' => theme('item_list', $itemListVariables)
    );
}